@extends('layouts.default') @section('main')
    <link rel="stylesheet" href="/css/uniform.css" />
    <link rel="stylesheet" href="/css/select2.css" />
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb"> <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a>
                <a href="#" >视频管理</a>
                <a href="#" class="current">视频评论管理</a> </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">
                    @if(in_array('add',$actions))<a href="{{url('activitytype/create')}}"><button class="btn">新增</button></a>@endif
                    <div class="widget-box">
                        <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
                            <h5>视频评论管理</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <table class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th>id</th>
                                    <th>视频名</th>
                                    <th>评论人</th>
                                    <th>评论内容</th>
                                    <th>父评论id</th>
                                    <th>获赞次数</th>
                                    <th>是否精彩</th>
                                    <th>评论级别</th>
                                    <th>被@的用户</th>
                                    <th>是否置顶</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($lists as $key => $list)
                                    <tr class="gradeX">
                                        <td>{{$list->id}}</td>
                                        <td>@if(isset($list->video)) {{$list->video->subject}} @endif</td>
                                        <td>@if(isset($list->user)) {{$list->user->realname or $list->user->nickname}} @endif</td>
                                        <td>{{cut_str($list->content, 20)}}</td>
                                        <td>@if($list->upid) {{$list->upid}} @else 无 @endif</td>
                                        <td>{{$list->likes}}</td>
                                        <td>@if($list->wonderful == 1)<i class="icon-ok"></i>@elseif($list->wonderful == 0)<i class="icon-question-sign"></i> @endif</td>

                                        <td>@if($list->upid) 二级 @else 一级 @endif</td>
                                        <td>@if(isset($list->rUser)) {{$list->user->realname or $list->user->nickname}} @endif</td>
                                        <td>@if($list->top == 1)<i class="icon-ok"></i>@elseif($list->top == 0)<i class="icon-remove"></i>@endif</td>
                                        <td class="center">
                                            @if($list->top!=1 && !$list->upid && in_array('top',$actions))<a data-original-title="置顶" data-toggle="modal" class="tip comment_top" c_id="{{$list->id}}" href="#myTop"><i class="icon-arrow-up"></i></a>@endif

                                                @if(in_array('edit',$actions)) <a data-original-title="修改" class="tip" href="{{url('activityvideocomment/edit?id='.$list->id)}}"> <i class="icon-pencil"></i> </a> @endif

                                             @if(in_array('delete',$actions))<a data-original-title="删除" data-toggle="modal" class="tip comment_delete" c_id="{{$list->id}}" href="#myDel"><i class="icon-remove"></i></a>@endif


                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>

                        <?php echo $lists->appends(['id' => $id])->render();?>
                </div>
            </div>
        </div>
    </div>

    <div>
        <div id="myDel" class="modal hide">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button">×</button>
                <h3>提示</h3>
            </div>
            <div class="modal-body">
                <p>确认要把这条评论删除吗？</p>
            </div>
            <div class="modal-footer">
                <a data-dismiss="modal" class="btn dbtn-primary" href="javascript:void(0);">确定</a>
                <a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
            </div>
        </div>
        <form action="{{url('activityvideocomment/delete')}}" method="post"
              id="delForm">
            <input type="hidden" name="dcid" value="0">
            <input type="hidden" name="dvid" value="{{$id}}">
        </form>
    </div>

    <div>
        <div id="myTop" class="modal hide">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button">×</button>
                <h3>提示</h3>
            </div>
            <div class="modal-body">
                <p>确认要把这条评论置顶吗？</p>
            </div>
            <div class="modal-footer">
                <a data-dismiss="modal" class="btn btn-primary" href="javascript:void(0);">确定</a>
                <a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
            </div>
        </div>
        <form action="{{url('activityvideocomment/top')}}" method="post"
              id="topForm">
            <input type="hidden" name="tcid" value="0">
            <input type="hidden" name="vid" value="{{$id}}">
        </form>
    </div>
    <script src="/js/matrix.tables.js"></script>
    <script src="/js/common.js"></script>
    <script>
        $(".comment_top").click(function(){
            var c_id = $(this).attr("c_id");
            $("input[name='tcid']").val(c_id);
        });
        $(".btn-primary").click(function(){
            var tc_id = $("input[name='tcid']").val();
            if(tc_id == 0){
                alert('参数异常');
                return;
            }
            ajaxRequest($('#topForm').serializeArray(),$('#topForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });


        $(".comment_delete").click(function(){
            var c_id = $(this).attr("c_id");
            $("input[name='dcid']").val(c_id);
        });
        $(".dbtn-primary").click(function(){
            var dc_id = $("input[name='dcid']").val();
            if(dc_id == 0){
                alert('参数异常');
                return;
            }
            ajaxRequest($('#delForm').serializeArray(),$('#delForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });


    </script>
@stop
